package com.zongzi.stock.utils;

import java.util.ArrayList;

/**
 * Created by Dell on 2017/6/9.
 */

public class Solution {
    public static ArrayList<ArrayList<Integer>> FindContinuousSequence(int sum) {
        ArrayList<ArrayList<Integer>> result = new ArrayList<>();
        if(sum <= 2){
            return result;
        }
        for(int i=1;i<=(sum/2 + 1);i++){
            ArrayList<Integer> temp = new ArrayList<>();
            int tempSum = 0;
            for(int j=i;j<=(sum/2 + 1);j++){
                temp.add(j);
                tempSum += j;
                if(tempSum > sum){
                    break;
                }else if(tempSum == sum){
                    result.add(temp);
                    for (int k=0;k<temp.size();k++){
                        System.out.print(temp.get(k) + " ");
                    }
                    System.out.println("");
                }
            }
        }
        return result;
    }
}
